﻿
var PDelta = function () {
    this.autocomplete = function (autId, autoUrl) {

        $(autId).autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: autoUrl + '?q=' + request.term,
                    type: "GET",
                    success: function (result) {
                        response($.map(result.predictions, function (item) { return { label: item.description, value: item.description} }));
                    }

                });
            },
            select: function (event, ui) {
                $(autId).val(ui.item ? ui.item.label : ui.item.label);
            }
        });
    };

    this.GetEvents = function (listingId, src) {

        var evnts = null;
        $.ajax(
        {
            url: src,
            dataType: "json",
            data: "{q:'" + listingId + "'}",
            async: false,
            success: function (result) {
                if (result.d.status == 'OK')
                    evnts = result.d.events;
            }
        });

        return evnts;
    }
};